import request from '../../plugins/request.js'

const userApi = {
  Login: '/api/login',
  Logout: '/api/login/out',
  GetYzm: '/api/getYzm',
  RestPass: '/api/rest/password',
}

/**
 * 登录
 * @param {*} data
 * @returns 
 */
export function login(username, password, yzm, type) {
  return request({
    url: userApi.Login,
    method: 'post',
    data: {
      "username": username,
      "password": password,
      "code": yzm,
      "type": type
    }
  })
}

/**
 * 登出
 */
export function userLoginOut() {
  return request({
    url: userApi.Logout,
    method: 'post',
    data: {}
  })
}

/**
 * 获取验证码
 */
export function getYzm(email) {
  return request({
    url: userApi.GetYzm,
    method: 'post',
    data: {
      "username": email,
    }
  })
}

/**
 * 重置密码
 */
export function restPassword(password) {
  return request({
    url: userApi.RestPass,
    method: 'put',
    data: {
      "password": password,
    }
  })
}